This directory contains the code for the cart and pendulum example in section 6.1 of
"Building Software for Simulation". Run the bash script 'build.sh' to construct three
executables: idealsim, mop, and inverted_pendulum. The executable 'idealsim' is
the ideal system in which the communication network imposes neither delay nor
lost data. The second executable 'mop' is used to calculate the metric of
performance for the control system. The third executable 'inverted_pendulum'
is the simulator that uses OMNET++ to model the Ethernet separating controller
and sensor.

The two simulators produces the output files 's.dat' and 'y.dat'. The file 's.dat' has the
arm angle of the cart. The file 'y.dat' has the output of the arm angle sensor. The
data is in two columns, the first for time (in seconds) and the second for the angle
(in degrees).

To build and execute this model you must install OMNET++ and its Inet extension.
These are available on the web at http://www.omnetpp.org/. You will need to edit
build.sh so that the OMNET_HOME and points to the directory where OMNET is installed
and INET_PROJ to point to where the Inet extensions are installed. Depending
on your compiler, the file Makefile.ideal will also need to be adjusted for
compiler flags and link libraries. Last, remember to put the OMNET++ bin directory
into your executable path (i.e., your PATH shell variable if you are using the bash
shell).

When the simulators are built, the experiments in the book can be repeated
with the bash script 'run.sh'. This script executes 11 runs of a single 
experiment. The parameters of the experiment (.e.g., the number of
retries at the MAC layer) can be adjusted by editting the omnet.ini file
(see the OMNET++ documentation if you are doing this). The script also provides 
an example of how to execute the OMNET++ simulator.
 
